package org.lw.provider.controller;



import org.lw.provider.Entity.User;
import org.lw.provider.response.ApiResponse;
import org.lw.provider.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{id}")
    public ResponseEntity<ApiResponse<User>> sayUser(@PathVariable("id") int id){
        System.out.println(userService);

        User user = userService.findUserById(id);
        return  ResponseEntity.ok().body(new ApiResponse<>(200,"返回给前端的数据",user));
    }
    @GetMapping("/spring")
    public String  saySpring(){

        return "springMVC";
    }

}
